package com.woniuxy.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * 评论互动表
 * @TableName article_comment
 */
@TableName(value ="article_comment")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ArticleComment {
    /**
     * 评论ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 关联帖子ID
     */
    @TableField("article_id") // 保留注解映射数据库字段
    private Long articleId;

    /**
     * 评论用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 评论内容
     */
    private String content;

    /**
     * 父评论ID（多级评论）
     */
    @TableField("parent_comment_id")
    private Long parentCommentId;

    /**
     * 是否删除
     */
    @TableLogic // 标记为逻辑删除字段
    @TableField("is_deleted")
    private Integer isDeleted;

    /**
     * 评论时间
     */
    @TableField("create_time")
    private Date createTime;
    /**
     * 子评论列表
     */
    @TableField(exist = false)
    private List<ArticleComment> replies; // 子评论列表
    /**
     * 用户昵称（非数据库字段）
     */
    @TableField(exist = false)
    private String nickname;

    /**
     * 用户头像（非数据库字段）
     */
    @TableField(exist = false)
    private String avatar;

//    @Override
//    public boolean equals(Object that) {
//        if (this == that) {
//            return true;
//        }
//        if (that == null) {
//            return false;
//        }
//        if (getClass() != that.getClass()) {
//            return false;
//        }
//        ArticleComment other = (ArticleComment) that;
//        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
//            && (this.getArticleId() == null ? other.getArticleId() == null : this.getArticleId().equals(other.getArticleId()))
//            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
//            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
//            && (this.getParentCommentId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
//            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()))
//            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
//    }
//
//    @Override
//    public int hashCode() {
//        final int prime = 31;
//        int result = 1;
//        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
//        result = prime * result + ((getArticleId() == null) ? 0 : getArticleId().hashCode());
//        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
//        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
//        result = prime * result + ((getParentCommentId() == null) ? 0 : getParentCommentId().hashCode());
//        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
//        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
//        return result;
//    }
//
//    @Override
//    public String toString() {
//        StringBuilder sb = new StringBuilder();
//        sb.append(getClass().getSimpleName());
//        sb.append(" [");
//        sb.append("Hash = ").append(hashCode());
//        sb.append(", id=").append(id);
//        sb.append(", article_id=").append(articleId);
//        sb.append(", user_id=").append(userId);
//        sb.append(", content=").append(content);
//        sb.append(", parent_comment_id=").append(parentCommentId);
//        sb.append(", is_deleted=").append(isDeleted);
//        sb.append(", create_time=").append(createTime);
//        sb.append("]");
//        return sb.toString();
//    }
}